package com.jt.ktdemo.dialog;

import android.content.Context;
import android.util.AttributeSet;

import com.aigestudio.wheelpicker.WheelPicker;

import java.util.ArrayList;
import java.util.List;

/**
 * 简单选择器
 */
public class WheelGenderPicker extends WheelPicker {

   public List<String> list ;

   public WheelGenderPicker(Context context) {
      this(context, null);
   }

   public WheelGenderPicker(Context context, AttributeSet attrs) {
      super(context, attrs);
      list = new ArrayList<>();
      updateSelectedYear(0);
   }

   /**
    * 赋值列表信息
    * @param listStrs    展示的信息
    */
   public void updateYears(List<String> listStrs) {
      this.list.clear();
      this.list.addAll(listStrs);
      super.setData(list);
   }

   /**
    * 设置默认
    */
   private void updateSelectedYear(int position) {
      setSelectedItemPosition(position);
   }

   @Override
   public void setData(List data) {
      throw new UnsupportedOperationException("You can not invoke setData in WheelGenderPicker");
   }

   @Override
   public List getData() {
      return list;
   }

   /**
    * 获取返回值
    * @return
    */
   public String getCurrentResult() {
      return String.valueOf(getData().get(getCurrentItemPosition()));
   }
}